# -*- coding: utf-8 -*-
# @Organization  : asiainfo
# @Author        : 周伟东
# @Time          : 2021/1/26 14:33
# @Function      : 重启任务
import logging

from flask_restful import Resource

from app.common.common_response_code import response_code


class InterfaceRestartJob(Resource):
    # 重启任务的请求
    def get(self, job_id):
        from app.dao.job_dao import jobDao
        flag = jobDao.restart_job(job_id)
        if flag:
            response = response_code.SUCCESS
            response['msg'] = "任务[%s]重启成功" % job_id
            logging.info("任务[%s]重启成功" % job_id)
        else:
            response = response_code.BAD_REQUEST
            response['msg'] = "任务[%s]无法重启" % job_id
            logging.info("任务[%s]无法重启" % job_id)
        return response
